#include "stdafx.h"
#include "CppUnitTest.h"

#include <HSModel/Model3DStorage.h>
#include <HSModel/Model3D.h>

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace HSModelTests
  {
  TEST_CLASS(Model3DStorageTests)
    {
    public:

      TEST_METHOD(ShouldAddModelWithoutShift)
        {
        std::shared_ptr<Model3D> p_model(new Model3D);
        auto id1 = p_model->AddPoint(TVector3(5, 0, 1));
        auto id2 = p_model->AddPoint(TVector3(6, 0, 0));
        auto id3 = p_model->AddPoint(TVector3(5, 1, 0));
        p_model->AddTriangle(id1, id2, id3);

        Model3DStorage model_storage;
        model_storage.AddModel("TestModel", p_model, TVector3(1, 1, 1), false);

        auto& model = model_storage.GetModel("TestModel");
        Assert::IsTrue(model.ContainsTriangle(TTriangle3(TVector3(5, 0, 1), TVector3(6, 0, 0), TVector3(5, 1, 0))));
        }

      TEST_METHOD(ShouldAddModelWithShift)
        {
        std::shared_ptr<Model3D> p_model(new Model3D);
        auto id1 = p_model->AddPoint(TVector3(-1, -1, 1));
        auto id2 = p_model->AddPoint(TVector3(0, 1, 0));
        auto id3 = p_model->AddPoint(TVector3(1, 0, 0));
        p_model->AddTriangle(id1, id2, id3);

        Model3DStorage model_storage;
        model_storage.AddModel("TestModel", p_model, TVector3(2, 2, 1));

        auto& model = model_storage.GetModel("TestModel");
        Assert::IsTrue(model.ContainsTriangle(TTriangle3(TVector3(-1, -1, 1), TVector3(0, 1, 0), TVector3(1, 0, 0))));
        }
    };
  }